home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / d3_xUtils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  16.7 KB  |  501 lines

  1. /*****************************************************************************
  2.   FILE           : d3_xUtils.c
  3.   SHORTNAME      : xUtils.c
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : command and toggle buttons for the pannels
  7.   NOTES          : analog to ui_xWidgets.c
  8.  
  9.   AUTHORS        : Tilman Sommer and Ralf Huebner
  10.   DATE           : 1.12.1991
  11.  
  12.   CHANGED BY     :
  13.   IDENTIFICATION : @(#)d3_xUtils.c    1.8 3/2/94
  14.   SCCS VERSION   : 1.8
  15.   LAST CHANGE    : 3/2/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.              
  19. ******************************************************************************/
  20.  
  21.  
  22. #include "ui.h"
  23.  
  24. #include <X11/Xlib.h>
  25. #include <X11/StringDefs.h>
  26. #include <X11/Intrinsic.h>
  27.  
  28. #include <X11/Xaw/Form.h>
  29. #include <X11/Xaw/Command.h>
  30. #include <X11/Xaw/Toggle.h>
  31.  
  32. #include "done.xbm"
  33. #include "done2.xbm"
  34. #include "control.xbm"
  35. #include "testL.xbm"
  36. #include "setup.xbm"
  37. #include "units.xbm"
  38. #include "links.xbm"
  39. #include "light.xbm"
  40. #include "clear.xbm"
  41. #include "project.xbm"
  42. #include "options.xbm"
  43. #include "display.xbm"
  44. #include "model.xbm"
  45. #include "parallel.xbm"
  46. #include "central.xbm"
  47. #include "on.xbm"
  48. #include "off.xbm"
  49. #include "ok.xbm"
  50. #include "up.xbm"
  51. #include "down.xbm"
  52. #include "prev.xbm"
  53. #include "next.xbm"
  54. #include "activation.xbm"
  55. #include "initact.xbm"
  56. #include "output.xbm"
  57. #include "bias.xbm"
  58. #include "name.xbm"
  59. #include "number.xbm"
  60. #include "zvalue.xbm"
  61. #include "nothing.xbm"
  62. #include "size.xbm"
  63. #include "color.xbm"
  64. #include "color2.xbm"
  65. #include "label.xbm"
  66. #include "toplabel.xbm"
  67. #include "bottlabel.xbm"
  68. #include "wire.xbm"
  69. #include "solid.xbm"
  70. #include "open.xbm"
  71. #include "close.xbm"
  72. #include "plus.xbm"
  73. #include "minus.xbm"
  74. #include "freeze.xbm"
  75. #include "reset.xbm"
  76. #include "small.xbm"
  77. #include "big.xbm"
  78.  
  79. #include "glob_typ.h"
  80. #include "ui_xWidgets.h"
  81.  
  82. #include "d3_global.h"
  83.  
  84. #include "d3_xUtils.ph"
  85.  
  86.  
  87. /*****************************************************************************
  88.   FUNCTION : d3_xCreateButtonItem
  89.  
  90.   PURPOSE  : creates a command button
  91.   RETURNS  : the command widget
  92.   NOTES    :
  93.  
  94.   UPDATE   :
  95. ******************************************************************************/
  96.  
  97. Widget d3_xCreateButtonItem (char *name, Widget parent, Widget left, Widget top)
  98.  
  99. {
  100.     Cardinal n;
  101.     Widget   w;
  102.     Arg         arg[15];
  103.     
  104.     n = 0;
  105.     if (strcmp (name, "done") == 0)
  106.       {  
  107.         XtSetArg(arg[n], XtNbitmap, 
  108.                   (Pixmap) XCreateBitmapFromData (ui_display,
  109.                    XDefaultRootWindow (ui_display), 
  110.                    done_bits, done_width, done_height)); n++;
  111.       } 
  112.      if (strcmp (name, "done2") == 0)
  113.       {  
  114.         XtSetArg(arg[n], XtNbitmap, 
  115.                   (Pixmap) XCreateBitmapFromData (ui_display,
  116.                    XDefaultRootWindow (ui_display), 
  117.                    done2_bits, done2_width, done2_height)); n++;
  118.       } 
  119.     if (strcmp (name, "control") == 0)
  120.       {  
  121.         XtSetArg(arg[n], XtNbitmap, 
  122.                   (Pixmap) XCreateBitmapFromData (ui_display,
  123.                    XDefaultRootWindow (ui_display), 
  124.                    control_bits, control_width, control_height)); n++;
  125.       } 
  126.     if (strcmp (name, "testL") == 0)
  127.       {  
  128.         XtSetArg(arg[n], XtNbitmap, 
  129.                   (Pixmap) XCreateBitmapFromData (ui_display,
  130.                    XDefaultRootWindow (ui_display), 
  131.                    testL_bits, testL_width, testL_height)); n++;
  132.       }
  133.     if (strcmp (name, "setup") == 0)
  134.       {  
  135.         XtSetArg(arg[n], XtNbitmap, 
  136.                   (Pixmap) XCreateBitmapFromData (ui_display,
  137.                    XDefaultRootWindow (ui_display), 
  138.                    setup_bits, setup_width, setup_height)); n++;
  139.       } 
  140.     if (strcmp (name, "project") == 0)
  141.       {  
  142.         XtSetArg(arg[n], XtNbitmap, 
  143.                   (Pixmap) XCreateBitmapFromData (ui_display,
  144.                    XDefaultRootWindow (ui_display), 
  145.                    project_bits, project_width, project_height)); n++;
  146.       } 
  147.     if (strcmp (name, "links") == 0)
  148.       {  
  149.         XtSetArg(arg[n], XtNbitmap, 
  150.                   (Pixmap) XCreateBitmapFromData (ui_display,
  151.                    XDefaultRootWindow (ui_display), 
  152.                    links_bits, links_width, links_height)); n++;
  153.       } 
  154.     if (strcmp (name, "model") == 0)
  155.       {  
  156.         XtSetArg(arg[n], XtNbitmap, 
  157.                   (Pixmap) XCreateBitmapFromData (ui_display,
  158.                    XDefaultRootWindow (ui_display), 
  159.                    model_bits, model_width, model_height)); n++;
  160.       } 
  161.     if (strcmp (name, "light") == 0)
  162.       {  
  163.         XtSetArg(arg[n], XtNbitmap, 
  164.                   (Pixmap) XCreateBitmapFromData (ui_display,
  165.                    XDefaultRootWindow (ui_display), 
  166.                    light_bits, light_width, light_height)); n++;
  167.       } 
  168.     if (strcmp (name, "units") == 0)
  169.       {  
  170.         XtSetArg(arg[n], XtNbitmap, 
  171.                   (Pixmap) XCreateBitmapFromData (ui_display,
  172.                    XDefaultRootWindow (ui_display), 
  173.                    units_bits, units_width, units_height)); n++;
  174.       } 
  175.     if (strcmp (name, "options") == 0)
  176.       {  
  177.         XtSetArg(arg[n], XtNbitmap, 
  178.                   (Pixmap) XCreateBitmapFromData (ui_display,
  179.                    XDefaultRootWindow (ui_display), 
  180.                    options_bits, options_width, options_height)); n++;
  181.       } 
  182.     if (strcmp (name, "freeze") == 0)
  183.       {  
  184.         XtSetArg(arg[n], XtNbitmap, 
  185.                   (Pixmap) XCreateBitmapFromData (ui_display,
  186.                    XDefaultRootWindow (ui_display), 
  187.                    freeze_bits, freeze_width, freeze_height)); n++;
  188.       } 
  189.     if (strcmp (name, "display") == 0)
  190.       {  
  191.         XtSetArg(arg[n], XtNbitmap, 
  192.                   (Pixmap) XCreateBitmapFromData (ui_display,
  193.                    XDefaultRootWindow (ui_display), 
  194.                    display_bits, display_width, display_height)); n++;
  195.       } 
  196.     if (strcmp (name, "clear") == 0)
  197.       {  
  198.         XtSetArg(arg[n], XtNbitmap, 
  199.                   (Pixmap) XCreateBitmapFromData (ui_display,
  200.                    XDefaultRootWindow (ui_display), 
  201.                    clear_bits, clear_width, clear_height)); n++;
  202.       } 
  203.     if (strcmp (name, "ok") == 0)
  204.       {  
  205.         XtSetArg(arg[n], XtNbitmap, 
  206.                   (Pixmap) XCreateBitmapFromData (ui_display,
  207.                    XDefaultRootWindow (ui_display), 
  208.                    ok_bits, ok_width, ok_height)); n++;
  209.       } 
  210.     if (strcmp (name, "up") == 0)
  211.       {  
  212.         XtSetArg(arg[n], XtNbitmap, 
  213.                   (Pixmap) XCreateBitmapFromData (ui_display,
  214.                    XDefaultRootWindow (ui_display), 
  215.                    up_bits, up_width, up_height)); n++;
  216.       } 
  217.     if (strcmp (name, "down") == 0)
  218.       {  
  219.         XtSetArg(arg[n], XtNbitmap, 
  220.                   (Pixmap) XCreateBitmapFromData (ui_display,
  221.                    XDefaultRootWindow (ui_display), 
  222.                    down_bits, down_width, down_height)); n++;
  223.       } 
  224.     if (strcmp (name, "open") == 0)
  225.       {  
  226.         XtSetArg(arg[n], XtNbitmap, 
  227.                   (Pixmap) XCreateBitmapFromData (ui_display,
  228.                    XDefaultRootWindow (ui_display), 
  229.                    open_bits, open_width, open_height)); n++;
  230.       } 
  231.     if (strcmp (name, "close") == 0)
  232.       {  
  233.         XtSetArg(arg[n], XtNbitmap, 
  234.                   (Pixmap) XCreateBitmapFromData (ui_display,
  235.                    XDefaultRootWindow (ui_display), 
  236.                    close_bits, close_width, close_height)); n++;
  237.       } 
  238.     if (strcmp (name, "prev") == 0)
  239.       {  
  240.         XtSetArg(arg[n], XtNbitmap, 
  241.                   (Pixmap) XCreateBitmapFromData (ui_display,
  242.                    XDefaultRootWindow (ui_display), 
  243.                    prev_bits, prev_width, prev_height)); n++;
  244.       } 
  245.     if (strcmp (name, "next") == 0)
  246.       {  
  247.         XtSetArg(arg[n], XtNbitmap, 
  248.                   (Pixmap) XCreateBitmapFromData (ui_display,
  249.                    XDefaultRootWindow (ui_display), 
  250.                    next_bits, next_width, next_height)); n++;
  251.       } 
  252.     if (strcmp (name, "plus") == 0)
  253.       {  
  254.         XtSetArg(arg[n], XtNbitmap, 
  255.                   (Pixmap) XCreateBitmapFromData (ui_display,
  256.                    XDefaultRootWindow (ui_display), 
  257.                    plus_bits, plus_width, plus_height)); n++;
  258.       } 
  259.     if (strcmp (name, "minus") == 0)
  260.       {  
  261.         XtSetArg(arg[n], XtNbitmap, 
  262.                   (Pixmap) XCreateBitmapFromData (ui_display,
  263.                    XDefaultRootWindow (ui_display), 
  264.                    minus_bits, minus_width, minus_height)); n++;
  265.       } 
  266.     if (strcmp (name, "reset") == 0)
  267.       {  
  268.         XtSetArg(arg[n], XtNbitmap, 
  269.                   (Pixmap) XCreateBitmapFromData (ui_display,
  270.                    XDefaultRootWindow (ui_display), 
  271.                    reset_bits, reset_width, reset_height)); n++;
  272.       } 
  273. /*
  274.     if (strcmp (name, "") == 0)
  275.       {  
  276.         XtSetArg(arg[n], XtNbitmap, 
  277.                   (Pixmap) XCreateBitmapFromData (ui_display,
  278.                    XDefaultRootWindow (ui_display), 
  279.                    _bits, _width, _height)); n++;
  280.       } 
  281. */
  282.  
  283.     XtSetArg(arg[n], XtNborderWidth, 0); n++;
  284.     XtSetArg(arg[n], XtNinternalHeight, 1); n++;
  285.     XtSetArg(arg[n], XtNinternalWidth , 1); n++;
  286.  
  287.     XtSetArg(arg[n], XtNfromVert , top);  n++;
  288.     XtSetArg(arg[n], XtNfromHoriz, left);  n++;
  289.     XtSetArg(arg[n], XtNleft  , XtChainLeft); n++;
  290.     XtSetArg(arg[n], XtNright , XtChainLeft); n++;
  291.     XtSetArg(arg[n], XtNtop   , XtChainTop); n++;
  292.     XtSetArg(arg[n], XtNbottom, XtChainTop); n++;
  293.     w = XtCreateManagedWidget(name, commandWidgetClass, parent, arg, n);
  294.     return(w);
  295.  
  296. }
  297.  
  298.  
  299. /*****************************************************************************
  300.   FUNCTION : d3_xCreateToggleItem
  301.  
  302.   PURPOSE  : creates a toggle button
  303.   RETURNS  : the toggle widget
  304.   NOTES    :
  305.  
  306.   UPDATE   :
  307. ******************************************************************************/
  308.  
  309. Widget  d3_xCreateToggleItem(char *name, Widget parent, Widget group, Widget left, Widget top)
  310.  
  311.     Cardinal n;
  312.     Widget   w;
  313.     Arg         arg[15];
  314.  
  315.     n = 0;
  316.  
  317.     if (strcmp (name, "parallel") == 0)
  318.       {  
  319.         XtSetArg(arg[n], XtNbitmap, 
  320.                   (Pixmap) XCreateBitmapFromData (ui_display,
  321.                    XDefaultRootWindow (ui_display), 
  322.                    parallel_bits, parallel_width, parallel_height)); n++;
  323.       } 
  324.     if (strcmp (name, "central") == 0)
  325.       {  
  326.         XtSetArg(arg[n], XtNbitmap, 
  327.                   (Pixmap) XCreateBitmapFromData (ui_display,
  328.                    XDefaultRootWindow (ui_display), 
  329.                    central_bits, central_width, central_height)); n++;
  330.       } 
  331.     if (strcmp (name, "on") == 0)
  332.       {  
  333.         XtSetArg(arg[n], XtNbitmap, 
  334.                   (Pixmap) XCreateBitmapFromData (ui_display,
  335.                    XDefaultRootWindow (ui_display), 
  336.                    on_bits, on_width, on_height)); n++;
  337.       } 
  338.     if (strcmp (name, "off") == 0)
  339.       {  
  340.         XtSetArg(arg[n], XtNbitmap, 
  341.                   (Pixmap) XCreateBitmapFromData (ui_display,
  342.                    XDefaultRootWindow (ui_display), 
  343.                    off_bits, off_width, off_height)); n++;
  344.       } 
  345.  
  346.     if (strcmp (name, "activation") == 0)
  347.       {  
  348.         XtSetArg(arg[n], XtNbitmap, 
  349.                   (Pixmap) XCreateBitmapFromData (ui_display,
  350.                    XDefaultRootWindow (ui_display), 
  351.                    activation_bits, activation_width, activation_height)); n++;
  352.       }
  353.     if (strcmp (name, "initact") == 0)
  354.       {  
  355.         XtSetArg(arg[n], XtNbitmap, 
  356.                   (Pixmap) XCreateBitmapFromData (ui_display,
  357.                    XDefaultRootWindow (ui_display), 
  358.                    initact_bits, initact_width, initact_height)); n++;
  359.       } 
  360.     if (strcmp (name, "output") == 0)
  361.       {  
  362.         XtSetArg(arg[n], XtNbitmap, 
  363.                   (Pixmap) XCreateBitmapFromData (ui_display,
  364.                    XDefaultRootWindow (ui_display), 
  365.                    output_bits, output_width, output_height)); n++;
  366.       } 
  367.     if (strcmp (name, "bias") == 0)
  368.       {  
  369.         XtSetArg(arg[n], XtNbitmap, 
  370.                   (Pixmap) XCreateBitmapFromData (ui_display,
  371.                    XDefaultRootWindow (ui_display), 
  372.                    bias_bits, bias_width, bias_height)); n++;
  373.       } 
  374.     if (strcmp (name, "name") == 0)
  375.       {  
  376.         XtSetArg(arg[n], XtNbitmap, 
  377.                   (Pixmap) XCreateBitmapFromData (ui_display,
  378.                    XDefaultRootWindow (ui_display), 
  379.                    name_bits, name_width, name_height)); n++;
  380.       } 
  381.     if (strcmp (name, "number") == 0)
  382.       {  
  383.         XtSetArg(arg[n], XtNbitmap, 
  384.                   (Pixmap) XCreateBitmapFromData (ui_display,
  385.                    XDefaultRootWindow (ui_display), 
  386.                    number_bits, number_width, number_height)); n++;
  387.       } 
  388.     if (strcmp (name, "zvalue") == 0)
  389.       {  
  390.         XtSetArg(arg[n], XtNbitmap, 
  391.                   (Pixmap) XCreateBitmapFromData (ui_display,
  392.                    XDefaultRootWindow (ui_display), 
  393.                    zvalue_bits, zvalue_width, zvalue_height)); n++;
  394.       } 
  395.     if (strcmp (name, "nothing") == 0)
  396.       {  
  397.         XtSetArg(arg[n], XtNbitmap, 
  398.                   (Pixmap) XCreateBitmapFromData (ui_display,
  399.                    XDefaultRootWindow (ui_display), 
  400.                    nothing_bits, nothing_width, nothing_height)); n++;
  401.       } 
  402.     if (strcmp (name, "size") == 0)
  403.       {  
  404.         XtSetArg(arg[n], XtNbitmap, 
  405.                   (Pixmap) XCreateBitmapFromData (ui_display,
  406.                    XDefaultRootWindow (ui_display), 
  407.                    size_bits, size_width, size_height)); n++;
  408.       } 
  409.     if (strcmp (name, "color") == 0)
  410.       {  
  411.         XtSetArg(arg[n], XtNbitmap, 
  412.                   (Pixmap) XCreateBitmapFromData (ui_display,
  413.                    XDefaultRootWindow (ui_display), 
  414.                    color_bits, color_width, color_height)); n++;
  415.       } 
  416.     if (strcmp (name, "color2") == 0)
  417.       {  
  418.         XtSetArg(arg[n], XtNbitmap, 
  419.                   (Pixmap) XCreateBitmapFromData (ui_display,
  420.                    XDefaultRootWindow (ui_display), 
  421.                    color2_bits, color2_width, color2_height)); n++;
  422.       } 
  423.     if (strcmp (name, "label") == 0)
  424.       {  
  425.         XtSetArg(arg[n], XtNbitmap, 
  426.                   (Pixmap) XCreateBitmapFromData (ui_display,
  427.                    XDefaultRootWindow (ui_display), 
  428.                    label_bits, label_width, label_height)); n++;
  429.       } 
  430.     if (strcmp (name, "toplabel") == 0)
  431.       {  
  432.         XtSetArg(arg[n], XtNbitmap, 
  433.                   (Pixmap) XCreateBitmapFromData (ui_display,
  434.                    XDefaultRootWindow (ui_display), 
  435.                    toplabel_bits, toplabel_width, toplabel_height)); n++;
  436.       } 
  437.     if (strcmp (name, "bottlabel") == 0)
  438.       {  
  439.         XtSetArg(arg[n], XtNbitmap, 
  440.                   (Pixmap) XCreateBitmapFromData (ui_display,
  441.                    XDefaultRootWindow (ui_display), 
  442.                    bottlabel_bits, bottlabel_width, bottlabel_height)); n++;
  443.       } 
  444.     if (strcmp (name, "freeze") == 0)
  445.       {  
  446.         XtSetArg(arg[n], XtNbitmap, 
  447.                   (Pixmap) XCreateBitmapFromData (ui_display,
  448.                    XDefaultRootWindow (ui_display), 
  449.                    freeze_bits, freeze_width, freeze_height)); n++;
  450.       } 
  451.     if (strcmp (name, "wire") == 0)
  452.       {  
  453.         XtSetArg(arg[n], XtNbitmap, 
  454.                   (Pixmap) XCreateBitmapFromData (ui_display,
  455.                    XDefaultRootWindow (ui_display), 
  456.                    wire_bits, wire_width, wire_height)); n++;
  457.       } 
  458.     if (strcmp (name, "solid") == 0)
  459.       {  
  460.         XtSetArg(arg[n], XtNbitmap, 
  461.                   (Pixmap) XCreateBitmapFromData (ui_display,
  462.                    XDefaultRootWindow (ui_display), 
  463.                    solid_bits, solid_width, solid_height)); n++;
  464.       } 
  465.     if (strcmp (name, "small") == 0)
  466.       {  
  467.         XtSetArg(arg[n], XtNbitmap, 
  468.                   (Pixmap) XCreateBitmapFromData (ui_display,
  469.                    XDefaultRootWindow (ui_display), 
  470.                    small_bits, small_width, small_height)); n++;
  471.       } 
  472.     if (strcmp (name, "big") == 0)
  473.       {  
  474.         XtSetArg(arg[n], XtNbitmap, 
  475.                   (Pixmap) XCreateBitmapFromData (ui_display,
  476.                    XDefaultRootWindow (ui_display), 
  477.                    big_bits, big_width, big_height)); n++;
  478.       } 
  479.  
  480.     XtSetArg(arg[n], XtNborderWidth, 0 /*!*/); n++;
  481.     XtSetArg(arg[n], XtNradioGroup, group); n++;
  482.     XtSetArg(arg[n], XtNinternalHeight, 1); n++;
  483.     XtSetArg(arg[n], XtNinternalWidth , 1); n++;
  484.     XtSetArg(arg[n], XtNfromVert , top);  n++;
  485.     XtSetArg(arg[n], XtNfromHoriz, left);  n++;
  486.     XtSetArg(arg[n], XtNleft  , XtChainLeft); n++;
  487.     XtSetArg(arg[n], XtNright , XtChainLeft); n++;
  488.     XtSetArg(arg[n], XtNtop   , XtChainTop); n++;
  489.     XtSetArg(arg[n], XtNbottom, XtChainTop); n++;
  490.     w = XtCreateManagedWidget(name, toggleWidgetClass, parent, arg, n);
  491.     return(w);
  492. }
  493.  
  494.  
  495.  
  496.  
  497.  
  498. /* end of file */
  499. /* lines: 508 */
  500.